package com.wufan.day05.java1;

import java.time.Period;

/**
 * 类的结构：构造器的使用
 *
 * @author SongWufan
 * @date 2021/3/9 20:37
 */
public class PersonTest {
    public static void main(String[] args) {
        //创建类的对象：new + 构造器
        Person person = new Person();
        person.eat();
        Person person1 = new Person("TOM");
    }
}

class Person {
    String name;
    int age;

    /**
     * 构造器
     */
    public Person() {
        System.out.println("Person");
    }

    public Person(String name) {
        this.name = name;
    }

    public Person(String name, int age){
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println("吃饭");
    }

    public void study() {
        System.out.println("学习");
    }
}
